package com.lykj.modules.shop.service.impl;

import com.lykj.modules.shop.entity.UserBonus;
import com.lykj.modules.shop.excel.UserBonusExcel;
import com.lykj.modules.shop.vo.UserBonusVO;
import com.lykj.modules.shop.mapper.UserBonusMapper;
import com.lykj.modules.shop.service.UserBonusService;
import com.lykj.core.mp.base.BaseServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.math.BigDecimal;
import java.util.List;

/**
 * 红包表 服务实现类
 *
 * @author cxl
 * @since 2022-01-14
 */
@Service
public class UserBonusServiceImpl extends BaseServiceImpl<UserBonusMapper, UserBonus> implements UserBonusService {

	@Override
	public IPage<UserBonusVO> selectUserBonusPage(IPage<UserBonusVO> page, UserBonusVO userBonus) {
		return page.setRecords(baseMapper.selectUserBonusPage(page, userBonus));
	}

	/**
	 * 更改红包状态
	 * @param id
	 */
	@Override
	public void bonusStatus(Long id){
		baseMapper.bonusStatus(id);
	}

	/**
	 * 删除红包
	 * @param id
	 */
	@Override
	public void bonusDeleted(Long id){
		baseMapper.bonusDeleted(id);
	}

	/**
	 * 获取累计分红总额
	 * @param userId
	 */
	@Override
	public BigDecimal bonusTotal(Long userId){
		return baseMapper.bonusTotal(userId);
	}

	/**
	 * 获取累计分红总额
	 * @param orderId
	 */
	@Override
	public BigDecimal bonusTotalByOrder(@Param("orderId") Long orderId){
		return baseMapper.bonusTotalByOrder(orderId);
	}

	/**
	 * 获取累计分红总额
	 */
	@Override
	public BigDecimal sumBonus(){
		return baseMapper.sumBonus();
	}

	@Override
	public List<UserBonusExcel> export(UserBonusVO userBonus){
		return baseMapper.export(userBonus);
	}
}
